package com.yjd.user.controll;

import com.yjd.user.entity.User;
import com.yjd.user.restful.service.ILoginRsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 用户登陆控制器
 * Created by yangchangyan@yijiedai.com on 2018-12-25 18:01.
 */
@RestController
@RequestMapping("/user")
public class LoginController {

  @Autowired
  private ILoginRsService loginService;

  @RequestMapping("/login/{username}/{password}")
  public Map login(
    @PathVariable("username") String username,
    @PathVariable("password") String password
  ) throws Exception {

    User user = loginService.login(username, password);

    Map result = new HashMap();
    result.put("code","200");
    result.put("msg","OK");
    result.put("data", user);
    return result;
  }
}
